package uk.ac.lkl.takteen.energyapp;

import uk.ac.lkl.takteen.energyapp.data.EnergyAppProvider;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;

public class Challenges extends TabActivity {

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.energyapplist_tabs);

		TabHost tabHost = getTabHost();

		TabHost.TabSpec spec; // Resusable TabSpec for each tab
		Intent intent; // Reusable Intent for each tab

		// Create an Intent to launch an Activity for the tab (to be reused)
		// intent = new Intent().setClass(this, ActivePledgesList.class);
		intent = new Intent(Intent.ACTION_VIEW,
				EnergyAppProvider.USER_CHALLENGES_DIR, Challenges.this,
				UserChallengesList.class);
		// Initialize a TabSpec for each tab and add it to the TabHost
		spec = tabHost.newTabSpec("user challenges")
				.setIndicator("Challenges you created", null)
				.setContent(intent);
		tabHost.addTab(spec);

		// Do the same for the other tabs
		// intent = new Intent().setClass(this, ExpiredPledgesList.class);
		intent = new Intent(Intent.ACTION_VIEW,
				EnergyAppProvider.RECEIVED_CHALLENGES_DIR, Challenges.this,
				ReceivedChallengesList.class);
		spec = tabHost.newTabSpec("received challenges")
				.setIndicator("Challenges sent to you", null)
				.setContent(intent);
		tabHost.addTab(spec);

		if (getIntent().getFlags() == 1)
			tabHost.setCurrentTab(1);
		else
			tabHost.setCurrentTab(0);
	}

}
